<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link rel="stylesheet" href="${initParam.root}/css/table.css" type="text/css">
   <script type="text/javascript">
	 $(document).ready(function(){
		 $(".delMsgBtn").click(function(){
			 var no= $(this).parent().parent().children().eq(0).text(); 
			 alert(no);
			 if(confirm("쪽지를 삭제하시겠습니까?")){
				 var url=" ${initParam.root}common/deletePost.do?deleteCheck=1&post=${param.post}&postNum="+no;
				 $(location).attr('href',url);
			
			 }else{
				 return false;
			 }
		 }); 
	 }); 
 </script>
	<table border=1 class="registerMemberTable"  style="margin: 0 auto ; width: 650px" >		
		<thead align="center">
		<tr >
		<th>no</th>
			<th class="title" width="300px" >제목</th>
		<c:choose>
			<c:when test="${param.post=='send'}">					
				<th class="name">보낸시간</th>
			</c:when>
			<c:otherwise>				
				<th class="name">받은시간</th>	
			</c:otherwise>
		 </c:choose>
			 <th class="name">열람여부</th>	
			 <th class="name">삭제버튼</th>	
			</tr>
		</thead>	
		<tbody align="center">			
		 <c:forEach var="list" items="${requestScope.lvo.list}" >				
		<tr>
		<!-- 보낸 쪽지함에서 쪽지 내용확인하면 수신여부 변동 없음
			받은 쪽지함에서 내용 확인하면 수신여부 변경 -->
		 <c:choose>
		 <c:when test="${param.post=='send'}">
		 <td class="number">${list.postNumber }</td>	
		 <td class="title"><a href="${initParam.root}common/postShowContent.do?postNum=${list.postNumber}&check=${param.post}">${list.postTitle}</a></td>
		 </c:when>
		 <c:otherwise>	
		 	<td class="number">${list.postNumber }</td>	
			<td class="title"><a href="${initParam.root}common/postShowContent.do?postNum=${list.postNumber}&check=${param.post}">${list.postTitle}</a></td>
			</c:otherwise>
			</c:choose>
			<td class="name">${list.postTime}</td>
		 <c:choose>
		 	 <c:when test="${list.readCheck==0}">
			 	<td class="name">안읽음</td>	
			 </c:when>
			 <c:otherwise>
			 		<td class="name">읽음</td>	
			 </c:otherwise>
		 </c:choose>
			<td class="name"><input class="delMsgBtn" type="button" value="삭제"></td>
			</tr>
			</c:forEach> 
		</tbody>					
	</table><br></br>	
	<br><br>	
	<p class="paging" align="center">
	<%-- 코드량을 줄이기 위해 pb 변수에 페이징 빈을 담는다 --%>
	<c:set var="pb" value="${requestScope.lvo.pagingBean}"></c:set> 
	 <%-- 페이징빈의 getNowPage에 접근하여 출력 --%>

	<c:if test="${pb.previousPageGroup&&sessionScope.login.authNumber==1}">
	<a href="${initParam.root }common/postList.do?pageNo=${pb.startPageOfPageGroup-1}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.customerId}">◀&nbsp; </a>	
	</c:if>
	<c:if test="${pb.previousPageGroup&&sessionScope.login.authNumber==11}">
	<a href="${initParam.root }common/postList.do?pageNo=${pb.startPageOfPageGroup-1}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.sellerId}">◀&nbsp; </a>	
	</c:if>
	<c:if test="${pb.previousPageGroup&&sessionScope.login.authNumber==100}">
	<a href="${initParam.root }common/postList.do?pageNo=${pb.startPageOfPageGroup-1}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.adminId}">◀&nbsp; </a>	
	</c:if>

	<c:forEach var="i" begin="${pb.startPageOfPageGroup}" 
	end="${pb.endPageOfPageGroup}">
	<c:choose>
	<c:when test="${pb.nowPage!=i&&sessionScope.login.authNumber==1}">
	<a href="${initParam.root }common/postList.do?pageNo=${i}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.customerId}" id="unselectedPage">${i}</a> 
	</c:when>
	<c:when test="${pb.nowPage!=i&&sessionScope.login.authNumber==11}">
	<a href="${initParam.root }common/postList.do?pageNo=${i}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.sellerId}" id="unselectedPage">${i}</a> 
	</c:when>
	<c:when test="${pb.nowPage!=i&&sessionScope.login.authNumber==100}">
	<a href="${initParam.root }common/postList.do?pageNo=${i}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.adminId}" id="unselectedPage">${i}</a> 
	</c:when>
	<c:otherwise>
	<span id="selectedPage">${i}</span>
	</c:otherwise>
	</c:choose>
	&nbsp;
	</c:forEach>	  
	
	 <c:if test="${pb.nextPageGroup&&sessionScope.login.authNumber==1}">
	<a href="${initParam.root }common/postList.do?pageNo=${pb.endPageOfPageGroup+1}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.customerId}">▶</a>
	</c:if>
	<c:if test="${pb.nextPageGroup&&sessionScope.login.authNumber==11}">
	<a href="${initParam.root }common/postList.do?pageNo=${pb.endPageOfPageGroup+1}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.sellerId}">▶</a>
	</c:if> 
	<c:if test="${pb.nextPageGroup&&sessionScope.login.authNumber==100}" >
	<a href="${initParam.root }common/postList.do?pageNo=${pb.endPageOfPageGroup+1}&post=${param.post}&auth=${sessionScope.login.authNumber }&id=${sessionScope.login.adminId}">▶</a>
	</c:if> 

	</p>

	